Titanium.include('../tableViews/TwitterTableView.js');

function _parseTwitterSearch(url)
{
	var xhr = Ti.Network.createHTTPClient();
	xhr.open("GET", url);
	xhr.onload = function(test){
		
		var refreshRow = _createTwitterRefreshRow();
		var twitterRowArray = [refreshRow];
		var tweets = JSON.parse(this.responseText).results;
		
		for (var i = 0; i < tweets.length; i++) 
		{
		    var tweet  = tweets[i].text; // The tweet message
		    var date   = tweets[i].created_at;
		    var user   = tweets[i].from_user; // The screen name of the user
		    var avatar = tweets[i].profile_image_url; // The profile image
		    
		    // meteen maar een row aanmaken dan?
		    var row = _createTwitterRow(tweet, user, avatar);
		    twitterRowArray.push(row);
		}
		
		Ti.API.info('de tweets: ' + tweets.results);
		Ti.API.info('array: ' + twitterRowArray);
		
		_tweetsLoaded(twitterRowArray);
	};
	
	xhr.send();
	
//	Ti.API.info('url: ' + url);
//	Ti.API.info(Titanium.JSON.parse(url));
}